package com.twetec.cms.common.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 权限类型
 */
public enum PermissionTypeEnum {

    MENU("MENU", "菜单"),
    BUTTON("BUTTON", "按钮");

    private String value;
    private String name;

    private PermissionTypeEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    // 整理返回数据, 键值对
    public static Map<String, String> list() {
        Map<String, String> list = new HashMap<>();
        for (PermissionTypeEnum genderEnum : PermissionTypeEnum.values()) {
            String name = genderEnum.getName();
            list.put(String.valueOf(genderEnum), name);
        }

        return list;
    }

    // 通过value获取name
    public static String getNameByValue(String value) {
        String name = "";
        for (PermissionTypeEnum genderEnum : PermissionTypeEnum.values()) {
            if (genderEnum.getValue().equals(value)) {
                name = genderEnum.getName();
            }
        }

        return name;
    }
}
